# Copyright 2010-2025 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(default_visibility = ["//ortools/math_opt:__subpackages__"])

cc_library(
    name = "math_opt_proto_utils",
    srcs = ["math_opt_proto_utils.cc"],
    hdrs = ["math_opt_proto_utils.h"],
    visibility = ["//visibility:public"],
    deps = [
        ":sparse_vector_view",
        "//ortools/base",
        "//ortools/base:status_macros",
        "//ortools/math_opt:callback_cc_proto",
        "//ortools/math_opt:infeasible_subsystem_cc_proto",
        "//ortools/math_opt:model_cc_proto",
        "//ortools/math_opt:model_parameters_cc_proto",
        "//ortools/math_opt:model_update_cc_proto",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/math_opt:solution_cc_proto",
        "//ortools/math_opt:sparse_containers_cc_proto",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "sparse_vector_view",
    hdrs = ["sparse_vector_view.h"],
    deps = [
        ":arrow_operator_proxy",
        ":sparse_vector",
        "//ortools/base",
        "//ortools/base:map_util",
        "//ortools/base:types",
        "//ortools/math_opt:sparse_containers_cc_proto",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/types:span",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_library(
    name = "model_summary",
    srcs = ["model_summary.cc"],
    hdrs = ["model_summary.h"],
    deps = [
        "//ortools/base:linked_hash_map",
        "//ortools/base:status_macros",
        "//ortools/math_opt:model_cc_proto",
        "//ortools/math_opt:model_update_cc_proto",
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "solver_interface",
    srcs = ["solver_interface.cc"],
    hdrs = ["solver_interface.h"],
    deps = [
        ":non_streamable_solver_init_arguments",
        "//ortools/base:map_util",
        "//ortools/base:status_macros",
        "//ortools/math_opt:callback_cc_proto",
        "//ortools/math_opt:infeasible_subsystem_cc_proto",
        "//ortools/math_opt:model_cc_proto",
        "//ortools/math_opt:model_parameters_cc_proto",
        "//ortools/math_opt:model_update_cc_proto",
        "//ortools/math_opt:parameters_cc_proto",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/port:proto_utils",
        "//ortools/util:solve_interrupter",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/synchronization",
    ],
)

cc_library(
    name = "solver",
    srcs = ["solver.cc"],
    hdrs = ["solver.h"],
    deps = [
        ":base_solver",
        ":concurrent_calls_guard",
        ":math_opt_proto_utils",
        ":model_summary",
        ":non_streamable_solver_init_arguments",
        ":solver_debug",
        ":solver_interface",
        "//ortools/base:status_macros",
        "//ortools/math_opt:callback_cc_proto",
        "//ortools/math_opt:infeasible_subsystem_cc_proto",
        "//ortools/math_opt:model_cc_proto",
        "//ortools/math_opt:model_parameters_cc_proto",
        "//ortools/math_opt:model_update_cc_proto",
        "//ortools/math_opt:parameters_cc_proto",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/math_opt/validators:callback_validator",
        "//ortools/math_opt/validators:infeasible_subsystem_validator",
        "//ortools/math_opt/validators:model_parameters_validator",
        "//ortools/math_opt/validators:model_validator",
        "//ortools/math_opt/validators:result_validator",
        "//ortools/math_opt/validators:solve_parameters_validator",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "non_streamable_solver_init_arguments",
    srcs = ["non_streamable_solver_init_arguments.cc"],
    hdrs = ["non_streamable_solver_init_arguments.h"],
    deps = ["//ortools/math_opt:parameters_cc_proto"],
)

cc_library(
    name = "solver_debug",
    srcs = ["solver_debug.cc"],
    hdrs = ["solver_debug.h"],
    deps = ["//ortools/base:base_export"],
)

cc_library(
    name = "arrow_operator_proxy",
    hdrs = ["arrow_operator_proxy.h"],
)

cc_library(
    name = "sparse_vector",
    hdrs = ["sparse_vector.h"],
)

cc_library(
    name = "sparse_submatrix",
    srcs = ["sparse_submatrix.cc"],
    hdrs = ["sparse_submatrix.h"],
    deps = [
        ":sparse_vector",
        ":sparse_vector_view",
        "//ortools/base:logging",
        "//ortools/math_opt:sparse_containers_cc_proto",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "inverted_bounds",
    srcs = ["inverted_bounds.cc"],
    hdrs = ["inverted_bounds.h"],
    deps = [
        "//ortools/base:status_macros",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "invalid_indicators",
    srcs = ["invalid_indicators.cc"],
    hdrs = ["invalid_indicators.h"],
    deps = [
        "//ortools/base:status_macros",
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "concurrent_calls_guard",
    srcs = ["concurrent_calls_guard.cc"],
    hdrs = ["concurrent_calls_guard.h"],
    deps = [
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/synchronization",
    ],
)

cc_library(
    name = "empty_bounds",
    srcs = ["empty_bounds.cc"],
    hdrs = ["empty_bounds.h"],
    deps = [
        "//ortools/math_opt:result_cc_proto",
        "//ortools/util:fp_roundtrip_conv",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "sorted",
    hdrs = ["sorted.h"],
    deps = [
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_library(
    name = "base_solver",
    srcs = ["base_solver.cc"],
    hdrs = ["base_solver.h"],
    deps = [
        "//ortools/math_opt:callback_cc_proto",
        "//ortools/math_opt:infeasible_subsystem_cc_proto",
        "//ortools/math_opt:model_cc_proto",
        "//ortools/math_opt:model_parameters_cc_proto",
        "//ortools/math_opt:model_update_cc_proto",
        "//ortools/math_opt:parameters_cc_proto",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/util:solve_interrupter",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:string_view",
    ],
)
